﻿using Lightray.Hattrick.ChppLib.EntityTypes;

namespace Lightray.Hattrick.ChppLib
{
    public struct ProgressRecord
    {
        public ProgressCharacteristic Characteristic { get; private  set; }
        public ProgressType Type { get; private  set; }
        public ProgressAttributes AffectedAttribute { get; private set; }
        public Skill AffectedSkill { get; private set; }
        public PlayerRole AffectedRole { get; private set; }

        public static ProgressRecord PositiveTrainingProgress(Skill s)
        {
            return skillProgress(ProgressCharacteristic.Positive, s);
        }

        public static ProgressRecord NegativeTrainingProgress(Skill s)
        {
            return skillProgress(ProgressCharacteristic.Negative, s);
        }

        public static ProgressRecord PositiveAbilityProgress(PlayerRole r)
        {
            return roleProgress(ProgressCharacteristic.Positive, r);
        }

        public static ProgressRecord NegativeAbilityProgress(PlayerRole r)
        {
            return roleProgress(ProgressCharacteristic.Negative, r);
        }

        public static ProgressRecord PlayerJoinedTeam()
        {
            return squadChange(ProgressType.PlayerJoined);
        }

        public static ProgressRecord PlayerLeftTeam()
        {
            return squadChange(ProgressType.PlayerLeft);
        }

        public static ProgressRecord PositiveGeneralProgress(ProgressAttributes a)
        {
            return generalProgress(ProgressCharacteristic.Positive, a);
        }

        public static ProgressRecord NegativeGeneralProgress(ProgressAttributes a)
        {
            return generalProgress(ProgressCharacteristic.Negative, a);
        }

        private static ProgressRecord roleProgress(ProgressCharacteristic c, PlayerRole r)
        {
            return new ProgressRecord()
            {
                Type = ProgressType.PlayerAttributeChanged,
                AffectedAttribute = ProgressAttributes.RoleScore,
                AffectedRole = r,
                Characteristic = c,

            };
        }

        private static ProgressRecord generalProgress(ProgressCharacteristic c, ProgressAttributes a)
        {
            return new ProgressRecord()
            {
                Type = ProgressType.PlayerAttributeChanged,
                AffectedAttribute = a,                
                Characteristic = c,
            };
        }

        private static ProgressRecord skillProgress(ProgressCharacteristic c, Skill s)
        {
            return new ProgressRecord()
            {
                Type = ProgressType.PlayerAttributeChanged,
                AffectedAttribute = ProgressAttributes.Skill,
                AffectedSkill = s,
                Characteristic = c,                
            };
        }

        private static ProgressRecord squadChange(ProgressType t)
        {
            return new ProgressRecord()
            {
                Characteristic = ProgressCharacteristic.Neutral,
                Type = t,
                 
            }; 
        }      
    }  
}